import { newCDsResponse } from './model/CD.d'
import { bannerList, bannerResponse } from './model/banner.d'
import service from '@/utils/request'
import { type } from 'os'
import { recommendSongListResponse, songListItem } from './model/songList'
import { songListResponse } from './model/song'
import { album } from './model/album'

export async function reqPlayList(id: number, limit?: number, offset?: number) {
  const query = limit ? `&limit=${limit}` : ''

  return service.get<any, songListResponse>(
    `/playlist/track/all?id=${id}` + query
  )
}
//轮播图
export async function reqBanners() {
  return service.get<any, bannerResponse>('/banner?type=0')
}
export async function reqEntries() {
  return service.get('/homepage/dragon/ball')
}

export async function reqSearchWord() {
  return service.get('/search/default')
}
export async function reqIndexMes() {
  return service.get('/homepage/block/page')
}
//推荐歌单
export async function reqRecommendSongList(limit?: number) {
  let query = limit ? `?limit=${limit}` : ''
  return service.get<any, recommendSongListResponse>('/personalized' + query)
}
//新碟上架
export const reqNewCD = (limit?: number) => {
  let newCD = limit ? `?limit=${limit}` : ''

  return service.get<any, newCDsResponse>('/album/list' + newCD)
}

//排行榜

export const reqRankDetail = () => {
  return service.get('/toplist/detail')
}

//获取歌单歌曲
export async function reqSongOfSongList(id: number) {
  return service.get('/playlist/track/all?id=' + id)
}

export async function reqSearch(str: string) {
  return service.get('/cloudsearch?keywords=' + str)
}
export async function reqBlock() {
  return service.get('/homepage/block/page')
}

//获取精品歌单 可选参数 cat limit:默认数量 before:分页参数
export const reqGetList = (data: any) => {
  return service.get<any, any | object>(
    `/top/playlist/highquality?${
      data.before ? 'before=' + data.before : ''
    }&limit=${data.limit}`
  )
}

//获取精品歌单列表下拉列表数据
export const reqTagsApi = () => {
  return service.get<any>('/playlist/highquality/tags')
}

//新碟上架
export const reqAlbumApi = (type: string, limit?: number, offset?: number) => {
  type = type ? `?type=` + type : ''

  let offsetstr = offset ? `&offset=` + offset : ''
  let limitstr = limit ? `&limit=` + limit : ''

  return service.get<any, { albums: album[] }>(
    // '/top/album' + type + offsetstr + limitstr
    '/album/new?area=ALL' + offsetstr + limitstr
  )
}
///top/album

//获取所有歌单数据 必选参数:id 可选参数 :limit 可选参数 : offset
///playlist/track/all
